/**  nodejs 如何访问数据库 */
var mysql = require('mysql');

var db = {
    host     : 'localhost',
    user     : 'root',
    password : '12345678',
    database : 'study'
}

var conn = mysql.createConnection(db);
//连接
conn.connect(); 

var sql= 'select * from p_users'
var sql1 = "insert into p_users values(null,'谢锦福','123123',90000)"

conn.query(sql1,(err,result,fields)=>{
    if(err){
        console.log('执行失败',err);
        return;
    }
    console.log( result);
    // for(let r of result){
    //     console.log( r.id , r.username );
    // }
})

//关闭
conn.end();




